﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LanZhouBeefNoodles.Models;
using Microsoft.AspNetCore.Mvc;
using LanZhouBeefNoodles.ViewModels;

namespace LanZhouBeefNoodles.Controllers
{
    /// <summary>
    /// 主页控制器
    /// </summary>
    public class HomeController : Controller
    {
        private INoodleRepository m_noodleRepository;
        private IFeedbackRepository m_feedbackRepository;
        public HomeController(INoodleRepository noodleRepository, IFeedbackRepository feedbackRepository)
        {
            m_noodleRepository = noodleRepository;
            m_feedbackRepository = feedbackRepository;
        }

        public IActionResult Index()
        {
            //var noodleList = m_noodleRepository.GetAllNoodles();
            var viewModel = new HomeViewModel()
            {
                Feedbacks = m_feedbackRepository.GetAllFeedbacks(),
                Noodles = m_noodleRepository.GetAllNoodles()
            };
            return View(viewModel);
        }

        public string About()
        {
            return "Hello From About";
        }

        public IActionResult Detail(int id)
        {
            var noodle = m_noodleRepository.GetNoodleById(id);
            return View(noodle);
        }
    }
}